1. Field of the Invention
This invention relates to an image processing method and apparatus for effecting the pattern matching of an input image and a pre-memorized reference image.
2. Related Background Art
There is known an image processing apparatus in which an input image including images of various patterns is compared with a reference image of predetermined pattern by a pattern matching technique to thereby discriminate between the reference image and a pattern image identical or similar thereto, and the relative position occupied in the input image by the identical or similar pattern image is found.
As such a pattern matching technique, there is a technique whereby images to be compared equal in size to the reference image are successively cut out from the input image from which a cross-correlation is to be taken, and without these images to be compared and the reference image being binarized but with these images remaining to be gradation images, the cross-correlation values thereof are successively found and the position occupied in the input image by the image to be compared having a pattern image identical or similar to the reference image is found from these cross-correlation values. In this case, in order to eliminate the influence by the brightness or contrast of the image, it is practiced to normalize the cross-correlation values by the mean value and dispension value of the image.
The calculation of the cross-correlation is effected by finding with respect to the images S to be compared which are successively cut out from the input image and the reference image T, dispersions Ds and Dt ##EQU1## and the co-dispersion Dst of the images S and T ##EQU2## and calculating, from these dispersions Ds and Dt and the co-dispersion Dst, the correlation coefficient C.sub.ST ##EQU3## Here, M is the number of picture elements in the area wherein cross-correlation calculation is to be effected in X-direction, and N is the number of picture elements in such area in Y-direction.
The correlation coefficient C.sub.ST assumes a value within the range of -1.ltoreq.C.sub.ST .ltoreq.1, and assumes a value of C.sub.ST =1 when the images S to be compared coincide with the reference image T, and assumes a value of C.sub.ST =0 when there is no correlation.
Generally, the input image is larger than the reference image. Accordingly, images to be compared equal in size to the reference image are successively cut out from the input image from which the cross-correlation is to be taken, and the correlation coefficient C.sub.ST is found with respect to each of the images to be compared. Pattern matching is effected with the position of the image to be compared which assumes the local maximum value of the correlation exceeding a predetermined threshold value as a location at which it coincides with the reference image.
In the pattern matching by cross correlation, the information of the gradation distribution of the entire pattern is used and matching is effected with this as the feature of each image, and this leads to the advantage that even if there is a variation in brightness or contrast between the images S to be compared and the reference image T, the recognition of the pattern can be accomplished relatively reliably and also, even if there is a minor defect in the pattern, the pattern can be recognized.
However, in the pattern matching by the cross-correlation calculation according to the prior art, when a pattern 61 as shown in FIG. 12 of the accompanying drawings which comprises only contours by a line drawing is used as the reference image T, information as gradation is little, and this has led to the possibility of wrong recognition.
Also, in the pattern matching by the cross-correlation calculation according to the prior art, the recognition of a pattern is effected by seeing the coincident state of the gradation distribution of the entire pattern and therefore, if the gradation distribution itself of this pattern partly varies, accurate pattern recognition will become difficult. Further, if with a view to enhance the speed of the calculation process, compression and averaging are effected on the images S to be compared which have been cut out from the input image or the reference image T, the information of the gradation distribution will be harmed by compression and averaging because the pattern 61 as shown in FIG. 12 which comprises only contours has a sensitive gradation distribution only in the edge portion thereof, and as a result, the possibility of the wrong recognition of the images S to be compared relative to the reference image T will become high.
Particularly, where the contour line of a pattern is based on the unevenness of an object, the pattern 61 as shown in FIG. 12 which comprises only contours will readily become a pattern 62, 63 or 64 as shown in FIG. 13 of the accompanying drawings, depending on the direction of light applied to the object. An image including the contour pattern 61 shown in FIG. 12 and an image including the pattern 62, 63 or 64 shown in FIG. 13 entirely differ in the gradation distribution thereof from each other. This has led to the problem that in the pattern matching by the cross-correlation calculation, the patterns differing in the gradation distribution thereof from each other are recognized as different ones.